feat(cli): enhance folder trust with configuration discovery and security warnings - #19492
Conversation
…rity warnings Implement FolderTrustDiscoveryService to safely scan untrusted folders for local configurations and security-sensitive settings. Update the trust dialog to display these findings, providing users with transparency into what will be loaded before they grant trust. - Add FolderTrustDiscoveryService for read-only .gemini directory scanning - Detect commands, skills, MCP servers, hooks, and setting overrides - Flag security risks such as disabled sandboxes or auto-approved tools - Update FolderTrustDialog to display discovery results and warnings - Integrate discovery into useFolderTrust hook for real-time scanning - Ensure dialog remains usable in small terminals with scrolling/truncation
Summary of ChangesHello @galz10, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly upgrades the Folder Trust mechanism in the Gemini CLI. It introduces a proactive discovery process that inspects local Highlights
Changelog
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a discovery phase for folder trust, significantly enhancing security transparency by scanning the .gemini directory and informing users about local configurations and potential risks. A critical vulnerability has been identified: the rendering of discovered items in the terminal is susceptible to terminal injection via ANSI escape sequences, which could allow an attacker to bypass security warnings and trick users into trusting malicious folders. This highlights the importance of treating all user-provided data as untrusted and applying proper sanitization. Additionally, the discovery service requires improvements in robustness, specifically regarding the validation of parsed configuration files from untrusted sources and proper management of asynchronous operations to prevent unhandled promise rejections.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
Size Change: +13 kB (+0.05%) Total Size: 24.6 MB
ℹ️ View Unchanged
|
- Robust JSON Parsing: Update `FolderTrustDiscoveryService` to handle non-object, null, or array values in `settings.json` without crashing, and add regression tests for these cases. - Type Safety: Fix unsafe type assertions in `FolderTrustDiscoveryService` using type guards (`isRecord`) and `instanceof Error` for better runtime safety and ESLint compliance. - ANSI Stripping: Use `strip-ansi` in `FolderTrustDialog` to ensure that raw ANSI escape codes from discovery errors, security warnings, or settings are not rendered as text in the UI. - UI Refinements: - Update `MaxSizedBox` to use `theme.text.secondary` for truncation messages. - Fix `Scrollable` auto-scroll logic to correctly identify "at bottom" state and default to top-aligned scrolling for new content unless `scrollToBottom` is explicitly set. - Test Improvements: Update `FolderTrustDialog` tests to properly wait for rendering (`waitUntilReady`) and add coverage for ANSI stripping.
…rity warnings (#19492) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…rity warnings (#19492) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…rity warnings (google-gemini#19492) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…rity warnings (google-gemini#19492) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…rity warnings (google-gemini#19492) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…rity warnings (#19492) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…rity warnings (google-gemini#19492) Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Summary
This PR enhances the Folder Trust mechanism by introducing a "Discovery" phase. Before a user trusts a folder, the CLI now safely scans the
.geminidirectory to inform the user about what local configurations will be loaded (commands, skills, MCP servers, and settings). It also proactively flags security-sensitive settings—such as disabled sandboxes or auto-approved tools—using clear visual warnings.Details
Related Issues
Related to the ongoing security and folder trust enhancement initiative.
How to Validate
```bash
npm test -w @google/gemini-cli -- src/services/FolderTrustDiscoveryService.test.ts src/ui/components/FolderTrustDialog.test.tsx src/ui/hooks/useFolderTrust.test.ts
```
```bash
npm run lint -w @google/gemini-cli
npm run typecheck -w @google/gemini-cli
```
Pre-Merge Checklist